package com.situ.mall.controller.front;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.situ.mall.entity.Product;
import com.situ.mall.service.IProductService;
import com.situ.mall.service.impl.ProductServiceImpl;

@Controller
@RequestMapping("/product")
public class FrontProductController {

	@Autowired
	private IProductService productService;
	@RequestMapping("/getProductListPage.shtml")
	public String getProductListPage(Integer categoryId, Model model) {
		List<Product> list = productService.selectProductByCategoryId(categoryId);
		model.addAttribute("list", list);
		
		return "product_list";
	}
	
	@RequestMapping("/getProductDetailPage.shtml")
	public String getProductDetailPage(Integer productId, Model model) {
		Product product = productService.selectById(productId);
		model.addAttribute("product", product);
		
		return "product_detail";
	}
}
